package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemoFour {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add("python");
        c1.add("php");
        System.out.println("c1:" + c1);

        Collection c2 = new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("c");
        System.out.println("c2:" + c2);
        System.out.println("~~~~~~~~~~~~~~~");
        c1.addAll(c2);//添加c2

        //是否包含c2
        System.out.println("c1:" + c1);

        System.out.println(c1.containsAll(c2));
        c1.retainAll(c2);//取c1和c2的交集
        System.out.println("c1:" + c1);

        c1.removeAll(c2);//移除c1中与c2共有的元素
        System.out.println("c1:" + c1);
        System.out.println("c2:" + c2);
    }
}
